package cn.zcy.springboot_web.service.impl;

import cn.zcy.springboot_web.entity.User;
import cn.zcy.springboot_web.service.IUserService;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class UserServiceImpl implements IUserService {
    Logger logger= LoggerFactory.getLogger(IUserService.class);
    @Override
    public User selectUserById(Integer id) {
        Map<Integer,User> userMap=new HashMap<>();
        userMap.put(1,new User(1,"springboot",3,new Date()));
        userMap.put(2,new User(2,"spring",5));
        userMap.put(3,new User(3,"springMvc",3,new Date()));
        userMap.put(4,new User(4,"Mybatis",3,new Date()));

        logger.info("参数id="+id);
        User user = userMap.get(id);
        logger.info("查询的数据是="+user);
        return user;
    }

    @Override
    public List<User> selectUserList(User user) {
        List<User> userList =new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            userList.add(new User(i+1,"springBoot"+i,i+2));
        }
        return userList;
    }

    @Override
    public int addUser(User user) {
        logger.info("user新增="+user);
        return 1;
    }

    @Override
    public int updateUser(User user) {
        logger.info("修改成功"+user);
        return 1;
    }

    @Override
    public int deleteUserById(Integer id) {
        logger.info("删除成功");
        return 1;
    }
}
